export type Variable = {
  type: 'number' | 'string' | 'boolean';
  value: number | string | boolean;
};

/**
 * 全局变量管理
 */
class GlobalVariableManager {
  variables: Record<string, Variable> = {};

  init(variables: Record<string, Variable> = {}) {
    this.variables = variables;
  }

  reset() {
    this.variables = {};
  }

  /**
   * 设置全局属性, 使用 merge 方式
   * @param variables
   */
  setVariables(variables: Record<string, Variable> = {}) {
    this.variables = {
      ...this.variables,
      ...variables,
    };
  }
}

export default new GlobalVariableManager();
